<?php

namespace App\Observers;

use App\Jobs\ScheduleExpire;
use App\Models\Comment;
use App\Models\Schedule;

class ScheduleObserver
{

    /**
     * 监听创建前事件.
     *
     * @param Schedule $model
     * @return void
     */
    public function creating(Schedule $model)
    {

    }

    /**
     * 监听创建事件.
     *
     * @param Schedule $model
     * @return void
     */
    public function created(Schedule $model)
    {
        $job = (new ScheduleExpire($model))
            ->delay(date_create($model->end_time));

        dispatch($job);
    }

    public function updating(Schedule $model)
    {

    }

    /**
     * 监听更新后事件.
     *
     * @param Schedule $model
     * @return void
     */
    public function updated(Schedule $model)
    {

    }

    /**
     * 监听删除事件.
     *
     * @param Schedule $model
     * @return void
     */
    public function deleting(Schedule $model)
    {

    }

    /**
     * 监听删除事件.
     *
     * @param Schedule $model
     * @return void
     */
    public function deleted(Schedule $model)
    {

    }

}
